<script setup>
import { useRouter } from "vue-router";
import { ref, onBeforeMount } from "vue";
const router = useRouter();
let usename = ref();
let currentIndex = ref(0);
onBeforeMount(() => {
  usename.value = localStorage.getItem("username");
  active({
    name: "全部课程",
    active: true,
    index: 0,
    childList: [
      {
        img: "./img/quanshenranzhi.png",
        childName: "全身燃脂",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/65/V-176570-5BB4DA18.mp4",
      },
      {
        img: "./img/qixing.png",
        childName: "骑行",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/14/70/V-147069-44A09D61.mp4",
      },
      {
        img: "./img/yaofuxunlian.png",
        childName: "腰腹训练",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N842797190.mp4",
      },
      {
        img: "./img/xingzou.png",
        childName: "行走",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N956152028.mp4",
      },
      {
        img: "./img/tuntuixunlian.png",
        childName: "臀腿训练",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N1327141602.mp4",
      },
      {
        img: "./img/youyangcao.png",
        childName: "有氧操",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42524765912.mp4",
      },
      {
        img: "./img/shoubixunlian.png",
        childName: "手臂训练",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/60/V-176066-543B7745.mp4",
      },
      {
        img: "./img/paobu.png",
        childName: "跑步",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N547479210.mp4",
      },
      {
        img: "./img/yujia.png",
        childName: "瑜伽",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/77/V-177729-3DFED986.mp4",
      },
    ],
  });
});
let currentName = ref(router.currentRoute.value.fullPath.split("/")[1]);
const list = ref([
  {
    name: "全部课程",
    active: true,
    index: 0,
    childList: [
      {
        img: "./img/quanshenranzhi.png",
        childName: "全身燃脂",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/65/V-176570-5BB4DA18.mp4",
      },
      {
        img: "./img/qixing.png",
        childName: "骑行",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/14/70/V-147069-44A09D61.mp4",
      },
      {
        img: "./img/yaofuxunlian.png",
        childName: "腰腹训练",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N842797190.mp4",
      },
      {
        img: "./img/xingzou.png",
        childName: "行走",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N956152028.mp4",
      },
      {
        img: "./img/tuntuixunlian.png",
        childName: "臀腿训练",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N1327141602.mp4",
      },
      {
        img: "./img/youyangcao.png",
        childName: "有氧操",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42524765912.mp4",
      },
      {
        img: "./img/shoubixunlian.png",
        childName: "手臂训练",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/60/V-176066-543B7745.mp4",
      },
      {
        img: "./img/paobu.png",
        childName: "跑步",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N547479210.mp4",
      },
      {
        img: "./img/yujia.png",
        childName: "瑜伽",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/77/V-177729-3DFED986.mp4",
      },
    ],
  },
  {
    name: "全身燃脂",
    active: false,
    index: 1,
    childList: [
      {
        img: "./img/quanshenranzhi.png",
        childName: "全身燃脂",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/65/V-176570-5BB4DA18.mp4",
      },
      {
        img: "./img/yaofuxunlian.png",
        childName: "腰腹训练",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N842797190.mp4",
      },
      {
        img: "./img/tuntuixunlian.png",
        childName: "臀腿训练",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N1327141602.mp4",
      },
      {
        img: "./img/shoubixunlian.png",
        childName: "手臂训练",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/60/V-176066-543B7745.mp4",
      },
    ],
  },
  {
    name: "户外运动",
    active: false,
    index: 2,
    childList: [
      {
        img: "./img/qixing.png",
        childName: "骑行",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/14/70/V-147069-44A09D61.mp4",
      },
      {
        img: "./img/xingzou.png",
        childName: "行走",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N956152028.mp4",
      },
      {
        img: "./img/paobu.png",
        childName: "跑步",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42N547479210.mp4",
      },
    ],
  },
  {
    name: "有氧运动",
    active: false,
    index: 3,
    childList: [
      {
        img: "./img/youyangcao.png",
        childName: "有氧操",
        url: "https://imgs-qn.51miz.com/vcg/video/preview/51miz42524765912.mp4",
      },
      {
        img: "./img/yujia.png",
        childName: "瑜伽",
        url: "https://imgs-qn.51miz.com/preview/video/00/00/17/77/V-177729-3DFED986.mp4",
      },
    ],
  },
]);

let currentChildList = ref();
const active = (item) => {
  list.value.forEach((i) => {
    i.active = false;
  });

  currentChildList.value = item.childList;
  item.active = true;
};

const handleClick = (item) => {
  console.log(item.url);
  window.location.href = item.url;
};
</script>

<template>
  <header class="navigation">
    <div class="container">
      <div class="logo">
        <img src="/img/tubiao.png" alt="" />
      </div>
      <ul class="nav">
        <li class="">
          <a target="_self" href="#">首页</a>
        </li>
        <li class="">
          <div
            class="tess"
            href="./kecheng.html"
            @click="$router.push('/kecheng')"
            :class="currentName == 'kecheng' ? 'active1' : ''"
          >
            课程
          </div>
        </li>
        <li class="">
          <div
            class="tess"
            href="./jiaolian.vue"
            @click="$router.push('/jiaolian')"
          >
            认证教练
          </div>
        </li>
        <li class="">
          <div
            class="tess"
            href="./yundong.vue"
            @click="$router.push('/yundong')"
          >
            我的运动
          </div>
        </li>
        <li class="">
          <div
            class="tess"
            href="./guanyu.vue"
            @click="$router.push('/guanyu')"
          >
            关于
          </div>
        </li>
        <div class="form">
          <input type="text" placeholder="课程" />
          <div class="sousuo">
            <img src="/img/sousuo.png" alt="" />
          </div>
        </div>
      </ul>
    </div>
    <div class="individual" style="display: flex" v-if="usename == null"></div>

    <div
      class="personal-page"
      href=".gerenzhuye.vue"
      @click="$router.push('/gerenzhuye')"
    >
      <img src="/img/personaal.png" alt="" />
    </div>
  </header>

  <el-backtop :right="80" :bottom="80" />

  <section
    class="banner"
    style="
      background-image: url(./img/banner.png);
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
    "
  ></section>
  <section class="cate">
    <div class="cate1">
      <ul>
        <li
          v-for="(item, i) in list"
          :key="i"
          @click="active(item)"
          :class="item.active ? 'active' : ''"
        >
          {{ item.name }}
        </li>
      </ul>
    </div>
  </section>
  <section class="courelist">
    <div class="courelist1">
      <ul class="coure">
        <li
          @click="handleClick(item)"
          v-for="(item, index) in currentChildList"
          :key="index"
          class="clist"
          :style="{ backgroundImage: 'url(' + item.img + ')' }"
          style="
            background-repeat: no-repeat;
            background-size: cover;
            background-position: center;
            cursor: pointer;
          "
        >
          <div class="tags">{{ item.childName }}</div>
        </li>
      </ul>
    </div>
  </section>

  <footer>
    <div class="w help">
      <div class="liikee">
        <img src="/img/tubiaoblack.png" alt="" />
        <p>力量的接收者，力量的传递者</p>
      </div>
      <div class="fl">
        <dl>
          <dt>关于力刻</dt>
          <dd><a href="#">关于力刻</a></dd>
          <dd><a href="#">资料下载</a></dd>
          <dd><a href="#">查找课程</a></dd>
          <dd><a href="#">俱乐部</a></dd>
          <dd><a href="#">教练员+</a></dd>
          <dd><a href="#">联系我们</a></dd>
          <dd><a href="#">侵权投诉</a></dd>
          <dd><a href="#">隐私条款</a></dd>
        </dl>
      </div>
      <div class="fl2">
        <dl>
          <dt>产品与服务</dt>
          <dd><a href="#">APP</a></dd>
          <dd><a href="#">消费品</a></dd>
          <dd><a href="#">智能装备</a></dd>
        </dl>
      </div>
      <div class="fl2">
        <dl>
          <dt>其他</dt>
          <dd><a href="#">力刻公益</a></dd>
          <dd><a href="#">媒体</a></dd>
        </dl>
      </div>
      <div class="fl2">
        <dl>
          <dt>规范说明</dt>
          <dd><a href="#">社区规范</a></dd>
          <dd><a href="#">用户公约</a></dd>
          <dd><a href="#">规则百科</a></dd>
          <dd><a href="#">侵权投诉说明</a></dd>
        </dl>
      </div>

      <div class="fr coverage">
        <h5>力刻线下体验店</h5>
        <p>已经在全国开设多家线下体验店</p>
        <a href="#" style="color: black">查看详情 > </a>
      </div>
    </div>
  </footer>
</template>

<style>
a {
  text-decoration: none;
  color: white;
}
.tess {
  text-decoration: none;
  color: white;
  cursor: pointer;
}
.navigation {
  width: 100%;
  height: 100px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  background-color: black;
  margin: 0;
  padding: 0;
}
.container {
  width: 1000px;
  height: 100px;
  margin: 0 auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0;
}
.logo {
  width: 165px;
  height: 100px;
  background-color: rgb(85, 9, 156);
}
.logo img {
  width: 165px;
  height: 22px;
  padding: 38px 0;
}
.nav {
  list-style: none;
  width: 800px;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav li {
  width: 100px;
  font-size: 20px;
  text-align: center;
}
.nav li:hover {
  font-weight: bold;
}
.nav li:hover::after {
  content: "";
  width: 70%;
  height: 1px;
  display: block;
  margin: 0 auto;
  border-bottom: 4px solid #f81a05;
  padding: 1px;
}
.active1 {
  border: 3px solid blueviolet;
}

.form {
  width: 250px;
  height: 35px;
  display: flex;
  padding-left: 10px;
}
.form input {
  width: 245px;
  height: 30px;
  float: left;
  font-size: 14px;
  padding-left: 3px;
}
.sousuo {
  width: 35px;
  height: 35px;
}
.sousuo img {
  width: 25px;
  height: 25px;
  padding: 5px 10px;
  cursor: pointer;
}
.individual {
  float: right;
  width: 90px;
  height: 35px;
  position: relative;
  top: -62px;
  left: -100px;
}
.personal-page {
  float: right;
  width: 40px;
  height: 40px;
  position: relative;
  top: -70px;
  left: 50px;
}
.personal-page img {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.banner {
  margin-top: 100px;
  height: 580px;
}
.cate {
  width: 100%;
  height: 100px;
  background-color: rgb(233, 231, 229);
  margin: 40px 0;
  border-bottom: 4px solid black;
}
.cate1 {
  width: 800px;
  height: 100px;
  margin: 0 auto;
  background-color: rgb(192, 192, 223);
}
.cate1 ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.cate1 ul li {
  width: 85px;
  height: 50px;
  margin-top: 35px;
  text-align: center;
  cursor: pointer;
}
.cate1 ul li:hover {
  border-bottom: 3px solid red;
  font-weight: bold;
}
.active {
  border-bottom: 3px solid red;
}
.courelist {
  width: 100%;
}
.courelist1 {
  margin: 0 auto;
  width: 1140px;
}
.coure {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
.clist {
  width: 300px;
  height: 400px;
  margin-bottom: 30px;
}
.tags {
  font-size: 20px;
  color: white;
  text-align: center;
  margin-top: 360px;
  background-color: rgba(128, 0, 128, 0.264);
}

.w {
  width: 1190px;
  margin: 0 auto;
  display: flex;
}
.liikee {
  margin-top: 60px;
  text-align: center;
}
.liikee img {
  width: 200px;
  height: 30px;
}

.fl {
  margin-top: 50px;
  margin-left: 100px;
}
.fl2 {
  margin-top: 50px;
  margin-left: 100px;
}
.fr {
  margin-top: 300px;
}
footer {
  margin-top: 90px;
  height: 500px;
  background-color: #eaeaea;
}
footer a {
  color: #666666;
}

.help dt {
  height: 30px;
  font-weight: bold;
  font-size: 23px;
  color: #666;
}
.help dd {
  font-size: 15px;
  height: 15px;
  margin-top: 20px;
  margin-left: 0;
}
.coverage {
  width: 200px;
  height: 150px;
  background: url(../img/ico_footer.png) no-repeat;
}
.coverage h5 {
  padding-left: 25px;
}
.coverage p {
  font-size: 12px;
  color: #666666;
  line-height: 18px;
  width: 180px;
}
.coverage a {
  display: block;
  margin-top: 5px;
  width: 180px;
  text-align: right;
}
</style>
